<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="./template.xhtml">

    <ui:define name="head">
        <style type="text/css">
            .ui-treetable table {
                table-layout: fixed
            }
        </style>
    </ui:define>
    
    <ui:define name="title">
        TreeTable - <span class="subitem">Dynamic Columns</span>
    </ui:define>

    <ui:define name="description">
        Columns of TreeTable can be created dynamically using the p:columns component.
    </ui:define>

    <ui:param name="documentationLink" value="/components/treetable" />

    <ui:define name="implementation">
        
        <h:form id="form">
            <h:panelGrid columns="3" style="margin:10px 0">
                <p:outputLabel for="template" value="Template:" style="font-weight:bold"/>
                <p:inputText id="template" value="#{ttColumnsView.columnTemplate}" size="50"/>
                <p:commandButton update="tt" action="#{ttColumnsView.createDynamicColumns}" value="Update" process="@parent" icon="pi pi-refresh" />
            </h:panelGrid>
            
            <p:treeTable id="tt" value="#{ttColumnsView.root}" var="document">
                <f:facet name="header">
                    Document Viewer
                </f:facet>
                <p:columns value="#{ttColumnsView.columns}" var="column" headerText="#{column.header}">
                    <h:outputText value="#{document[column.property]}" />
                </p:columns>
            </p:treeTable>
        </h:form>
        
    </ui:define>

</ui:composition>